package com.derbysoft.dswitch.adapter.ihg.com.derbysoft.dswitch.adapter.ihg.dswitch3.global.service.impl;

import com.derbysoft.dswitch.dto.hotel.avail.HotelAvailCriteriaDTO;
import com.derbysoft.dswitch.dto.hotel.avail.HotelAvailRQ;
import com.derbysoft.dswitch.remote.hotel.dto.HotelAvailRequest;
import com.derbysoft.dswitch.remote.hotel.dto.HotelAvailResponse;

/**
 * User: jason
 * Date: 2013-04-19
 */
public class GetAvailTask extends IntegrationTestSupport implements Runnable {
    @Override
    public void run() {
        HotelAvailResponse availability = remoteService.getAvailability(createAvailRequest());
        System.out.println(toXml(availability));
    }

    private HotelAvailRequest createAvailRequest() {
        HotelAvailRequest hotelAvailRequest = new HotelAvailRequest();
        hotelAvailRequest.setHeader(createHeader());
        hotelAvailRequest.setHotelAvailRQ(createHotelAvailRQ());
        return hotelAvailRequest;
    }

    private HotelAvailRQ createHotelAvailRQ() {
        HotelAvailRQ hotelAvailRQ = new HotelAvailRQ();
        HotelAvailCriteriaDTO availCriteria = new HotelAvailCriteriaDTO();
        availCriteria.setHotelCodesList(createHotelPassport());
        availCriteria.setStayDateRange(createDateRange());
        availCriteria.setRoomStayCandidate(createRoomStayCandidate());
        hotelAvailRQ.setAvailCriteria(availCriteria);
        return hotelAvailRQ;
    }
}
